package com.hzjy.api.controller;


import com.hzjy.api.service.impl.VideoServiceImpl;
import com.hzjy.common.core.domain.AjaxResult;
import com.hzjy.common.utils.PageData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Api("影视版权")
@RestController
@RequestMapping("/api/video")
public class VideoController {

    @Autowired
    private VideoServiceImpl videoService;

    @ApiOperation("影视版权")
    @PostMapping("/videoList")
    public AjaxResult videoList(@RequestBody PageData pageData){
        Object currentPage = pageData.get("currentPage");
        if(currentPage == null){
            pageData.put("currentPage",0);
            pageData.put("pageSize",10);
        }else{
            pageData.put("currentPage",(Integer.parseInt(pageData.get("currentPage").toString())-1)*Integer.parseInt(pageData.get("pageSize").toString()));
        }
        List<PageData> hzjyWorksList = videoService.videoList(pageData);
        int total = videoService.videoListNum(pageData);
        Map map=new HashMap();
        map.put("tradeNewsList",hzjyWorksList);
        map.put("total",total);
        map.put("currentPage",currentPage);
        return AjaxResult.success(200,"成功",map);
    }
}
